<template>
	<view class="search-wrapper flex-x-bet-y-center" :style="style">
		<view class="flex-y-center flex-1">
			<u-icon name="search" color="#FE5A13" size="45" :bold="true"></u-icon>
			<input type="text" class="flex-1" :placeholder="placeHolderText" v-model.trim="keyword" :disabled="disabled"/>
		</view>
		<view class="search-btn flex-xy-center" @tap="searchConfirm">搜索</view>
	</view>
</template>

<script>
	export default {
		name:"InputSearch",
		props: {
			inputVal:{  // 指定输入框文字
				default: {}
			},
			placeHolderText: {
				default: '请输入关键词搜索……'
			},
			customStyle: {
				default: () => {}
			},
			disabled:{
				default: false
			}
		},
		data() {
			return {
				keyword: ''
			};
		},
		watch:{
			inputVal(val){
				this.keyword = val
			}
		},
		computed:{
			style(){
				let  str = ''
				for (let key in this.customStyle) {
					str += `${key}:${this.customStyle[key]};`
				}
				return str
			}
		},
		methods:{
			searchConfirm(){
				this.$emit('searchConfirm', this.keyword)
			}
		}
	}
</script>

<style lang="scss">
	.search-wrapper{
		position: relative;
		z-index: 99;
		background: #FFFFFF;
		border-radius: 38rpx;
		border: 2rpx solid $theme-color;
		padding: 10rpx 12rpx 10rpx 20rpx;
		
		input{
			margin: 0 20rpx;
			font-size: 29rpx;
			color: #666666;
			line-height: 35rpx;
			text-align: left;
			font-style: normal;
			text-transform: none;
		}
		
		.search-btn{
			width: 110rpx;
			height: 58rpx;
			background: #FE5A13;
			border-radius: 29rpx;
			font-size: 31rpx;
			color: #FFFFFF;
		}
	}
</style>